from django.contrib import admin

# Register your models here.
# 导入Comment数据模型
from .models import Post, Comment
from .models import Post
# 将文章表注册到管理后台，保持不动
#admin.site.register(Post)
@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
    list_display = ('title', 'slug', 'author', 'publish', 'status')
    list_filter = ('status', 'created', 'publish', 'author')
    search_fields = ('title', 'body')
    prepopulated_fields = {'slug': ('title',)}
    raw_id_fields = ('author',)
    date_hierarchy = 'publish'
# 新增如下代码将评论表注册到管理后台
@admin.register(Comment)
class CommentAdmin(admin.ModelAdmin): 
# 配置在管理后台可以查看到的字段 
  list_display = ('name', 'email', 'post', 'created', 'active') 
# 配置在管理后台可以进行过滤的字段 
  list_filter = ('active', 'created', 'updated') 
# 配置在管理后台可以进行搜索的字段 
  search_fields = ('name', 'email', 'body') 